package main

import (
	"context"
	"fmt"
	"github.com/gin-gonic/gin"
	rkboot "github.com/rookie-ninja/rk-boot"
	rkgin "github.com/rookie-ninja/rk-gin/boot"
	"net/http"
)

// Response.
type GreeterResponse struct {
	Message string
}

// @Summary Greeter service
// @Id 1
// @version 1.0
// @produce application/json
// @Param name query string true "Input name"
// @Success 200 {object} GreeterResponse
// @Router /v1/greeter [get]
func Greeter(ctx *gin.Context) {
	ctx.JSON(http.StatusOK, &GreeterResponse{
		Message: fmt.Sprintf("Hello %s!", ctx.Query("name")),
	})
}

// @title RK Swagger for Gin
// @version 1.0
// @description This is a greeter service with rk-boot.
func main() {
	boot := rkboot.NewBoot()

	// Register handler
	boot.GetEntry("greeter").(*rkgin.GinEntry).Router.GET("/v1/greeter", Greeter)

	// Bootstrap
	boot.Bootstrap(context.Background())

	// Wait for shutdown sig
	boot.WaitForShutdownSig(context.Background())
}

// @Summary Create a mytodo
// @Description Create a mytodo by GetTodoReq (base or vip)
// @Tags todos
// @Accept json
// @Produce json
// @Param req body GetTodoReq true "create todoList request message"
// @Success 200 {string} string "ok"
// @Failure 400 {string} string "bad request"
// @Failure 500 {string} string "Internal Server Error"
// @Router /todos [post]
func test(ctx *gin.Context) {
	fmt.Println("测试swagger")
}
